<template>
	<view>
		
		<orderCommon
			:text="text" :order="order" :afterSalesRecord="afterSalesRecord" :is_time="false" :is_chat="false"
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3">
		</orderCommon>
		
		<view class="cardBox" style="margin-top: 10rpx;">
			<view  style="margin-top: 10rpx;padding-bottom: 20rpx;">
				<text style="font-weight: bold;font-size:32rpx;">{{text.submit_user}} </text>
				<view >
					<image :src="IMAGE_URL+order.join_user.avatar" class="close_image2"></image>
					<view style="line-height: 140rpx;float: left;">
						<block v-if="lang==='zh'">{{order.join_user.username}}</block>
						<block v-if="lang==='ru'">{{order.join_user.username_ru}}</block>
					</view>
					<view style="line-height: 140rpx;float: right;">
						<text @click="chat_canyu(order.join_user.mobile)" style="background-color: orange;color: #fff;border-radius: 10rpx;padding: 5px 10px;">
							{{ $t('即时联系') }} 
						</text>
					</view>
					
					<view style="clear: both;"></view>
					<view class="flex" style="margin-top: 10rpx;padding-bottom: 20rpx;">
						{{text.afterNoAgree}}
					</view>
					<view class="flex" style="margin-top: 10rpx;padding-bottom: 20rpx;color: #999;">
						<view style="width: 50%;float: left; text-align: left;" >
							{{timestampToDate(afterSalesRecord.appeal_time*1000)}}
						</view>
					</view>
					<view style="clear: both;"></view>
					
				</view>
			</view>
		</view>
		
		
		<appealCommon @change2="edit" @change3="customer"
			:text="text" :order="order" :afterSalesRecord="afterSalesRecord" 
			:customStyle1="customStyle1" :customStyle11="customStyle11" 
			:customStyle2="customStyle2" :customStyle3="customStyle3">
		</appealCommon>
		
		
		
		
		<view style="height:5px"></view>
		
	</view>
</template>

<script>
	import {HTTP_REQUEST_URL,HTTP_IMG_UTL,IMAGE_URL} from "@/config/app";
	import orderCommon from './orderCommon.vue';
	import appealCommon from './appealCommon.vue';
	
	import {
		ImageUrl,
		isVideo,
		time,createC2CConversation
	} from "@/common/public";
	export default {
		components:{
			orderCommon,appealCommon
		},
		props:{
			order:{
				type:Object,
				default:{}
			},
			afterSalesRecord:{
				type:Object,
				default:{}
			},
			text:{
				type:Object,
				default:{}
			},
			customStyle1:{
				type:Object,
				default:{}
			},
			customStyle11:{
				type:Object,
				default:{}
			},
			customStyle2:{
				type:Object,
				default:{}
			},
			customStyle3:{
				type:Object,
				default:{}
			},
		},
		data() {
			return {
				//远程域名
				HTTP_IMG_UTL,
				HTTP_REQUEST_URL,
				IMAGE_URL,
				url: IMAGE_URL,
				
				//语言
				lang: this.$i18n.locale,
				
				img:HTTP_IMG_UTL+'huangjin.png',
				subDisabled:false,
				
				order_type:'',
				release_status:0,
				afterSalesRecord2:{}
				
			}
		},
		mounted(){
			console.log(this.order)
			//goods=货物,transport=运输,crossborder=跨境货代,professional=专业代办
			if(this.order.orderInfo.type=='goods'){
				this.order_type=this.$t('货物')
			}else if(this.order.orderInfo.type=='transport'){
				this.order_type=this.$t('运输')
			}else if(this.order.orderInfo.type=='crossborder'){
				this.order_type=this.$t('跨境货代')
			}else if(this.order.orderInfo.type=='professional'){
				this.order_type=this.$t('专业代办')
			}
			
			console.log(this.afterSalesRecord)
			
			this.release_do_time = this.afterSalesRecord.release_do_time
			this.release_status  = this.afterSalesRecord.release_status
			this.afterSalesRecord2 = this.afterSalesRecord
		},
		methods:{
			timestampToDate(timestamp) {
			  const date = new Date(timestamp); // 如果timestamp是数值，可以直接作为Date构造函数的参数
			  const year = date.getFullYear();
			  const month = (date.getMonth() + 1).toString().padStart(2, '0');
			  const day = date.getDate().toString().padStart(2, '0');
			  const hours = date.getHours().toString().padStart(2, '0');
			  const minutes = date.getMinutes().toString().padStart(2, '0');
			  const seconds = date.getSeconds().toString().padStart(2, '0');
			  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			},
			chat_canyu(mobile){
				createC2CConversation(mobile, this)
			},
			approve(release_status){
				const that = this
				that.$u.api.order.approveAppeal({
					release_status: release_status,
					aftersales_id :that.order.orderInfo.aftersales_id,
					lang:that.lang
				}).then(res => {
					uni.showModal({
						content: that.$t('操作成功'),
						showCancel: false,
						confirmText: this.$t('是'),
					})
					that.afterSalesRecord2 = res
					that.release_status= res.release_status
					that.release_do_time = res.release_do_time
					
					if(release_status==1){
						that.$emit('change','customer','approve')
					}
					
					return false;
				})
			},
			pingtai(){
				if(this.lang==='zh'){
					createC2CConversation(getApp().globalData.site.im_customer001, this,true)
				}else{
					createC2CConversation(getApp().globalData.site.im_customer002, this,true)
				}
			},
			edit(){
				this.$emit('change','customer','publisherEdit2',this.afterSalesRecord2)
			},
			customer(){
				this.$emit('change','customer','approve')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cardBox {
		width: 94%;
		margin: 0 auto;
		margin-top: 30rpx;
		box-shadow: 0 0 10px #ddd;
		background: #ddd;
		padding: 10rpx 20rpx;
		border-radius: 20rpx;
		background: #fff;
		margin-bottom: 30rpx;
		position: relative;
	}
	.flex{width: 100%;display: flex;}
	.biao{margin-top: 0rpx; width: 80%; margin-left: 0rpx;font-size: 30rpx;  font-weight: bold;}
	.biao_span{color:darkorange ; font-size: 18px; margin-right: 5px;}
	.cardTitle{font-size: 24rpx; width: 94%;padding-top: 6rpx;}
	.order_img{width: 160rpx;height: 160rpx;border-radius: 20rpx;}
	.close_image2{
		width: 120rpx;height: 120rpx;border-radius: 20rpx; margin-right: 20rpx; margin-top: 20rpx; float: left;
	}
</style>